﻿using System;
using System.Linq;
using System.IO;
using OpenExcel.OfficeOpenXml;

namespace OpenExcel_Examples
{
    public static class Example4
    {
        public static void Run()
        {
            Console.WriteLine("=== Running Example4 ===");
            string outputFile = Path.Combine(Program.OutputDirectory, "example4.xlsx");

            DateTime dtStart = DateTime.Now;
            uint cellCounter = 0;
            using (ExcelDocument doc = ExcelDocument.CreateWorkbook(outputFile))
            {
                ExcelWorksheet wsheet = doc.Workbook.Worksheets.Add("Test Strings");
                uint rowCount = 1000;
                uint colCount = 500;

                //for (uint r = rowCount; r >= 1; r--)
                //    for (uint c = colCount; c >= 1; c--)
                for (uint r = 1; r <= rowCount; r++)
                    for (uint c = 1; c <= colCount; c++)
                        wsheet.Cells[r, c].Value = "cell" + (++cellCounter);
                Program.LogTime(dtStart, "Created " + rowCount + " row(s) x " + colCount + " column(s)");
            }
            Program.LogTime(dtStart, "Saved file");
        }
    }
}
